package com.qf.ssm.controller;

import com.github.pagehelper.PageInfo;
import com.qf.ssm.qo.CarMaintenanceQO;
import com.qf.ssm.qo.CarMaintenanceReturnQO;
import com.qf.ssm.qo.CarRemindQo;
import com.qf.ssm.qo.CarServiceQO;
import com.qf.ssm.result.ResponseResult;
import com.qf.ssm.service.CarService;
import com.qf.ssm.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
 * 车辆服务管理控制器
 * */
@RestController
@RequestMapping("/car/service")
public class CarServiceController {
    @Autowired
    private CarService carService;


    @PostMapping("/list/insurance/{page}/{size}")
    public ResponseResult<PageInfo<CarInsuranceVO>> carInsuranceList(@PathVariable(value = "page") Integer page, @PathVariable(value = "size") Integer size, @RequestBody CarServiceQO carServiceQO){
        return ResponseResult.success(carService.queryCarInsuranceServiceList(page,size,carServiceQO));
    }

    @PostMapping("/list/annual_inspection/{page}/{size}")
    public ResponseResult<PageInfo<CarAnnualInspectionVo>> carAnnualInspectionList(@PathVariable(value = "page") Integer page, @PathVariable(value = "size") Integer size, @RequestBody CarServiceQO carServiceQO){
        return ResponseResult.success(carService.queryCarAnnualInspectionServiceList(page,size,carServiceQO));
    }

    @PostMapping("/list/maintenance/{page}/{size}")
    public ResponseResult<PageInfo<CarMaintenanceVO>> carMaintenanceList(@PathVariable(value = "page") Integer page, @PathVariable(value = "size") Integer size, @RequestBody CarServiceQO carServiceQO){
        return ResponseResult.success(carService.queryCarMaintenanceServiceList(page,size,carServiceQO));
    }

    @PostMapping("/edit/insurance")
    public ResponseResult<Integer> editCarInsurance(@RequestBody CarInsuranceVO carInsuranceVO){
        return ResponseResult.success(carService.modifyCarInsuranceInfo(carInsuranceVO));
    }

    @PostMapping("/edit/annual_inspection")
    public ResponseResult<Integer> editCarAnnualInspection(@RequestBody CarAnnualInspectionVo carAnnualInspectionVo){
        return ResponseResult.success(carService.modifyCarAnnualInspectionInfo(carAnnualInspectionVo));
    }

    @PostMapping("/edit/maintenance")
    public ResponseResult<Integer> editCarMaintenance(@RequestBody CarMaintenanceVO carMaintenanceVO){
        return ResponseResult.success(carService.modifyCarMaintenanceInfo(carMaintenanceVO));
    }


    @PostMapping("/add/maintenance")
    public ResponseResult<Integer> addCarMaintenance(@RequestBody CarMaintenanceQO carMaintenanceQO){
        return ResponseResult.success(carService.saveCarMaintenance(carMaintenanceQO));
    }

    @PostMapping("/edit/maintenance_return")
    public ResponseResult<Integer> editCarMaintenanceReturn(@RequestBody CarMaintenanceReturnQO carMaintenanceReturnQO){
        return ResponseResult.success(carService.modifyCarMaintenanceReturn(carMaintenanceReturnQO));
    }

    @GetMapping("/get/maintenance_detail")
    public ResponseResult<CarMaintenanceDetailVO> getCarMaintenanceDetail( int carId){
        return ResponseResult.success(carService.selectCarMaintenanceDetail(carId));
    }

    @PostMapping("/remind")
    public ResponseResult<CarRemindTimeVo> remind(@RequestBody CarRemindQo carRemindQo){
        return ResponseResult.success(carService.remind(carRemindQo));
    }
}
